<template>
  <div>
    <el-dialog title="卡位短信设置" :visible="dialogVisible" :close-on-click-modal="false" @close="close" width="800px">
     
      <el-form :model="ruleForm" ref="ruleForm" :inline="false" label-width="130px"  class="demo-ruleForm new_form_box">
        <el-form-item label="强制手机号查询:" prop="telNumForce">
            <el-switch v-model="ruleForm.telNumForce" :active-value="2" :inactive-value="1" active-color="#13ce66" inactive-color="#ff4949">
            </el-switch>
            <span class="tip">
              开启后，在短信列表必须输入手机号后方可查询短信列表
            </span>
        </el-form-item>
        <el-form-item label="短信内容展示:" prop="contentShow">
          <el-switch v-model="ruleForm.contentShow" :active-value="1" :inactive-value="2" active-color="#13ce66" inactive-color="#ff4949">
          </el-switch>
          <span class="tip">
              关闭后，隐藏短信内容，需手动点击查看短信，保留查看记录。
            </span>
        </el-form-item>
        <el-form-item label="新短信通知:" prop="smsNotice">
          <el-switch v-model="ruleForm.smsNotice" :active-value="1" :inactive-value="2" active-color="#13ce66" inactive-color="#ff4949">
          </el-switch>
          <span class="tip">
              关闭后，收到新短信时，系统右上角不再有通知提醒。
            </span>
        </el-form-item>
        <el-form-item label="短信通知关键词:" prop="filterWords" >
          <el-input  type="textarea" v-model="ruleForm.filterWords" rows="3" placeholder="请输入关键词，多个词用逗号隔开，设置后只弹出包含关键词的短信提醒"></el-input>
          
        </el-form-item>
        <div class="tip">
            多个关键词用逗号隔开，设置后只弹出包含关键词的短信提醒。
            </div>
      </el-form>
      <div class="center" style="margin-top: 15px;">
        <el-button @click="close()">取消</el-button>
        <el-button type="primary"  @click="submitForm()" >保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      dialogVisible: false,
      ruleForm: {
        telNumForce:1,//短信列表强制输入手机号查询  1不强制  2强制
        smsNotice:1,//新短信通知提醒， 1通知 2不通知
        filterWords:'',//新短信通知过滤词，包含设置的词的短信进行通知提醒
        contentShow:1//短信内容是否展示，1展示 2隐藏
      },
    };
  },
  created() {
   
  },
  methods: {
    open(data) {
      this.dialogVisible = true;
      if(data){
        const obj = JSON.parse(data)
        if(typeof obj === 'object' && obj !== null){
          this.ruleForm = {
            ...this.ruleForm,
            ...obj
          }
        }
      }else{
        this.ruleForm = {
          telNumForce:1,//短信列表强制输入手机号查询  1不强制  2强制
          smsNotice:1,//新短信通知提醒， 1通知 2不通知
          filterWords:'',//新短信通知过滤词，包含设置的词的短信进行通知提醒
          contentShow:1//短信内容是否展示，1展示 2隐藏
        }
      }
    },
    submitForm() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.$emit('save',this.ruleForm)
          this.close()
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
   
    close() {
      this.resetForm('ruleForm')
      this.dialogVisible = false;
    },
  },
};
</script>
<style scoped lang="scss">
.tip{
  color: #999;
  margin-left: 10px;
}
</style>
